<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of User
 *
 * @author Pablo Barrenechea
 */
class MD_UserCategory
{
    public static function getAll()
    {
    
        return TN_Db::getInstance()->fetchAll("SELECT * FROM user_category ORDER BY id");
    }
    
    public static function getName($id)
    {
    	$category = TN_Db::getInstance()->fetchAll("select name from user_category where id = '$id'");
    	return $category[0]['name'];
    }
    
    public static function add($name)
    {
    	TN_Db::getInstance()->insert('user_category', array('name'=> $name));
    }
    
    public static function update($id,$name)
    {
    	TN_Db::getInstance()->update('user_category', array( 'name'=> $name) , "id = '$id' ");
    }
    
    public static function delete($id)
    {
    	TN_Db::getInstance()->delete('user_category', "id = '$id' "); 
    }
    
    public static function lastId()
    {
    	return TN_Db::getInstance()->lastInsertId('user_category');
    }
}
?>